@import '~codemirror/lib/codemirror.css';
@import '~codemirror/addon/lint/lint.css';

// BASICS
.CodeMirror {
    font-family: $font-family-sansSerif;
    background: inherit;
}

// PADDING
.CodeMirror-lines {
    padding: .25rem 0; // Vertical padding around content
}
.CodeMirror pre {
    padding: 0 .25rem; // Horizontal padding of content
}

.CodeMirror-scrollbar-filler,
.CodeMirror-gutter-filler {
    background-color: transparent; // The little square between H and V scrollbars
}

// GUTTER
.CodeMirror-gutters {
    background: $editor-linenumber-bgColor;
    border-right: 1px solid darken($editor-linenumber-bgColor, 2%);
    white-space: nowrap;
}
//.CodeMirror-linenumbers {}
.CodeMirror-linenumber {
    // padding: .25rem 0;
    font-size: $font-size-xs;
    font-family: $font-family-monospace;
    min-width: 1rem;
    text-align: right;
    color: $editor-linenumber-color;
    white-space: nowrap;
}

.CodeMirror-activeline {
    .CodeMirror-linenumber {
        font-weight: bold;
        color: darken($editor-linenumber-color, 16%);
    }
}

/* CURSOR */

.CodeMirror-cursor {
    border-left: 2px solid $color800;
    border-right: none;
    width: 0;
}
/* Shown when moving in bi-directional text */
.CodeMirror .CodeMirror-secondarycursor {
    border-left: 1px solid silver;
}
.cm-fat-cursor .CodeMirror-cursor {
    width: auto;
    border: 0;
    background: #7e7;
}
.cm-fat-cursor .CodeMirror-cursors {
    z-index: 1;
}

.cm-animate-fat-cursor {
    width: auto;
    border: 0;
    -webkit-animation: blink 1.06s steps(1) infinite;
    animation: blink 1.06s steps(1) infinite;
    background-color: #7e7;
}
@-webkit-keyframes blink {
    0% {}
    50% { background-color: transparent; }
    100% {}
}
@keyframes blink {
    0% {}
    50% { background-color: transparent; }
    100% {}
}

/* Can style cursor different in overwrite (non-insert) mode */
.CodeMirror-overwrite .CodeMirror-cursor {}

.cm-tab { display: inline-block; text-decoration: inherit; }

.CodeMirror-ruler {
    border-left: 1px solid #ccc;
    position: absolute;
}

/* DEFAULT THEME */
.CodeMirror-composing { border-bottom: 2px solid; }

/* Default styles for common addons */
.CodeMirror CodeMirror-matchingbracket {color: #0f0;}
.CodeMirror CodeMirror-nonmatchingbracket {color: #f22;}
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }

// /* STOP */
// /* The rest of this file contains styles related to the mechanics of
//    the editor. You probably shouldn't touch them. */

.CodeMirror {
    position: relative;
    overflow: hidden;
    background: white;
}

.CodeMirror-scroll {
    overflow: scroll !important; /* Things will break if this is overridden */
    /* 30px is the magic margin used to hide the element's real scrollbars */
    /* See overflow: hidden in .CodeMirror */
    margin-bottom: -32px; margin-right: -32px;
    padding-bottom: 32px;
    height: 100%;
    outline: none; /* Prevent dragging from highlighting the element */
    position: relative;
}
.CodeMirror-sizer {
    position: relative;
    border-right: 32px solid transparent;
}

/* The fake, visible scrollbars. Used to force redraw during scrolling
before actual scrolling happens, thus preventing shaking and
flickering artifacts. */
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
    position: absolute;
    z-index: 6;
    display: none;
}
.CodeMirror-vscrollbar {
    right: 0; top: 0;
    overflow-x: hidden;
    overflow-y: scroll;
}
.CodeMirror-hscrollbar {
    bottom: 0; left: 0;
    overflow-y: hidden;
    overflow-x: scroll;
}
.CodeMirror-scrollbar-filler {
    right: 0; bottom: 0;
}
.CodeMirror-gutter-filler {
    left: 0; bottom: 0;
}

.CodeMirror-gutters {
    position: absolute; left: 0; top: 0;
    min-height: 100%;
    z-index: 3;
}
.CodeMirror-gutter {
    white-space: normal;
    //height: 100%;
    display: inline-block;
    vertical-align: top;
    margin-bottom: -30px;
}
.CodeMirror-gutter-wrapper {
    position: absolute;
    z-index: 4;
    background: none !important;
    border: none !important;
}
.CodeMirror-gutter-background {
    position: absolute;
    top: 0; bottom: 0;
    z-index: 4;
}
.CodeMirror-gutter-elt {
    position: absolute;
    cursor: default;
    z-index: 4;
}
.CodeMirror-gutter-wrapper {
    user-select: none;
}

.CodeMirror-lines {
    cursor: text;
    padding: 0;
    min-height: 1px; /* prevents collapsing before first draw */
}
.CodeMirror pre {
    /* Reset some styles that the rest of the page might have set */
    border-radius: 0;
    border-width: 0;
    background: transparent;
    font-family: inherit;
    font-size: inherit;
    margin: 0;
    white-space: pre;
    word-wrap: normal;
    line-height: inherit;
    color: inherit;
    z-index: 2;
    position: relative;
    overflow: visible;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-variant-ligatures: none;
    font-variant-ligatures: none;
}
.CodeMirror-wrap pre {
    word-wrap: break-word;
    white-space: pre-wrap;
    word-break: normal;
}

.CodeMirror-linebackground {
    position: absolute;
    left: 0; right: 0; top: 0; bottom: 0;
    z-index: 0;
}

.CodeMirror-linewidget {
    position: relative;
    z-index: 2;
    overflow: auto;
}

.CodeMirror-widget {}

.CodeMirror-code {
    outline: none;
}

.CodeMirror-measure {
    position: absolute;
    width: 100%;
    height: 0;
    overflow: hidden;
    visibility: hidden;
}

.CodeMirror-cursor { position: absolute; }
.CodeMirror-measure pre { position: static; }

.CodeMirror-cursors {
    visibility: hidden;
    position: relative;
    z-index: 3;
}
.CodeMirror-dragcursors {
    visibility: visible;
}

.CodeMirror-focused .CodeMirror-cursors {
    visibility: visible;
}

.CodeMirror-crosshair { cursor: crosshair; }

.CodeMirror-selected,
.CodeMirror-line::selection,
.CodeMirror-line > span::selection,
.CodeMirror-line > span > span::selection {
    border-radius: 2px;
    background: $selection-bgColor;
}

.cm-searching {
    background: rgba(255, 255, 0, .4);
}

/* Used to force a border model for a node */
.cm-force-border { padding-right: .1px; }

/* See issue #2901 */
.cm-tab-wrap-hack:after { content: ''; }

/* Help users use markselection to safely style text background */
CodeMirror-selectedtext { background: none; }


////////////

.CodeMirror-guttermarker {
    color: #ac4142;
}
.CodeMirror-guttermarker-subtle {
    color: #b0b0b0;//$color500
}
.cm-comment {
    color: $color600;
}
.cm-atom {
    color: #aa759f;
}
.cm-number {
    color: #aa759f;
}
.cm-attribute,
.cm-property {
    color: #90a959;
}
.cm-keyword {
    color: #ac4142;
}
.cm-string {
    color: #f4bf75;
}
.cm-variable {
    color: #90a959;
}
.cm-variable-2 {
    color: #6a9fb5;
}
.cm-def {
    color: #d28445;
}
.cm-bracket {
    color: #202020;
}
.cm-tag {
    color: #ac4142;
}
.cm-link {
    color: #aa759f;
}
.cm-error {
    background: #ac4142;
    color: #505050;
}
.CodeMirror-activeline-background {
    background: $editor-activeline-bgColor;
}

.CodeMirror-matchingbracket {
    text-decoration: underline;
    color: white !important;
}

// same: github-markdown style
.cm-header-1 { font-size: 32px; }
.cm-header-2 { font-size: 24px; }
.cm-header-3 { font-size: 20px; }
.cm-header-4 { font-size: 16px; }
.cm-header-5 { font-size: 14px; }
.cm-header-6 { font-size: 12px; }

.cm-header-1,
.cm-header-2,
.cm-header-3,
.cm-header-4,
.cm-header-5,
.cm-header-6 {
    font-weight: bold;
}

.cm-strong { font-weight: bold; }
.cm-em { font-style: italic; }
.cm-comment {
    font-family: $font-family-monospace;
}

.cm-hr,
.cm-formatting {
    color: $color500;
    font-family: $font-family-monospace;
    font-weight: bold;
}

// Lint
.CodeMirror-lint-mark-error {
    background: #ECACB5;
    border-radius: 2px;
}
.CodeMirror-lint-tooltip {
    color: $color50;
    background: $dark-black;
    font-size: $font-size-sm;
    font-family: $font-family-monospace;
}
.CodeMirror-lint-message-error {
    background-image: none;
    &::before {
        display: block;
        content: "●";
        color: #C7243A;
        font-size: 1rem;
        position: absolute;
        left: .5rem;
    }
}

// fold
.CodeMirror-foldmarker {
  line-height: .3;
  cursor: pointer;
  color: $color400;
  margin: .25rem;
}
.CodeMirror-foldgutter {
  width: 1rem;
}
.CodeMirror-foldgutter-open,
.CodeMirror-foldgutter-folded {
  cursor: pointer;
  &:after {
      display: block;
      text-align: center;
  }
}
.CodeMirror-foldgutter-open:after {
  content: "\25BE";
}
.CodeMirror-foldgutter-folded:after {
  content: "\25B8";
}
